package com.java110.mall.api.configuration;

import com.java110.mall.api.filter.JwtFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by wuxw on 2018/5/2.
 */
@Configuration
public class ServiceConfiguration {

    public static final StringBuffer exclusions = new StringBuffer();

    static {
        exclusions.append("/mall/api/register.pcUserRegister,");
        exclusions.append("/mall/api/login.supplyChainUserLogin,");
        exclusions.append("/mall/api/system.initPlatformData,");
        exclusions.append("/mall/api/goodsClass.listGoodsClassesTree,");
        exclusions.append("/mall/api/goodsClass.listGoodsClasses,");
        exclusions.append("/mall/api/register.messageCode,");
        exclusions.append("/mall/api/notify,");
        exclusions.append("/mall/api/information.listInformation,");
        exclusions.append("/mall/api/information.listInformationOther,");
        exclusions.append("/mall/api/product.listProductLabel,");
        exclusions.append("/mall/api/websiteAccessLog.saveWebsiteAccessLog,");

        exclusions.append("/mall/api/login.pcUserLogin,");
        exclusions.append("/mall/api/login.phoneWechatLogin,");
        exclusions.append("/mall/api/login.getSysInfo,");
        exclusions.append("/mall/api/system.listSystemInfo,");
        exclusions.append("/mall/api/login.generatorValidateCode,");
        exclusions.append("/mall/api/area.listAreas,");
        exclusions.append("/mall/api/area.listUserProvinceArea,");
        exclusions.append("/mall/api/shopType.queryShopType,");
        exclusions.append("/mall/api/shop.registerStoreAndShop,");
        exclusions.append("/mall/api/user.userSendSms,");
        exclusions.append("/mall/api/mallCommunity/getCommunity,");
        exclusions.append("/mall/api/shop.queryShopByUser,");
        exclusions.append("/mall/api/productCategory.queryMainCategoryAllGoods,");
        exclusions.append("/mall/api/housekeepingType.queryHousekeepingType,");
        exclusions.append("/mall/api/advert.listAdvertPhoto,");
        exclusions.append("/mall/api/mallAd.listMallAd,");
        exclusions.append("/mall/api/phone.*,");

        exclusions.append("/mall/api/productGroup.listProductGroup,");
        exclusions.append("/mall/api/productSeckill.listProductSeckill,");
        exclusions.append("/mall/api/productCategory.queryCategoryProducts,");
        exclusions.append("/mall/api/shopVisit/saveShopVisit,");
        exclusions.append("/mall/api/shop.queryShopByPhone,");
        exclusions.append("/mall/api/product.queryProduct,");
        exclusions.append("/mall/api/shopAppraise/queryShopAppraise,");
        exclusions.append("/mall/api/payment/notify,");//微信支付通知
        exclusions.append("/mall/api/payment/notify/*,");// 通用通知放开
        exclusions.append("/mall/api/payment/rentingNotify,");//微信支付通知
        exclusions.append("/mall/api/payment/servFeeNotify,");//服务支付
        exclusions.append("/mall/api/payment/bondFeeNotify,");//保证金支付
        exclusions.append("/mall/api/paymentGold/goldNotify,");//金币购买通知
        exclusions.append("/mall/api/goods/notify,");//商品购买通知
        exclusions.append("/mall/api/product.queryProductLabel,");//查询大类
        exclusions.append("/mall/api/file/userfile/download/*,");// 下载文件

        exclusions.append("/mall/api/convenienceMenus/queryConvenienceMenus,");//查询便民分类
        exclusions.append("/mall/api/storeInfo/queryStoreInfo,");//查询便民商家信息
        exclusions.append("/mall/api/storeInfo/queryStoreBySeq,");//查询便民商家信息
        exclusions.append("/mall/api/housekeepingType/queryHousekeepingType,");//查询商城菜单呢
        exclusions.append("/mall/api/housekeepingServ.queryHousekeepingServ,");//查询家政服务
        exclusions.append("/mall/api/convenienceMenus/queryConvenienceMenus,");//查询大类
        exclusions.append("/mall/api/shopMenu.listShopMenu,");//查询大类


        exclusions.append("/mall/api/housekeepingFeeConfig/queryServFeeConfig,");//查询服务费用配置
        exclusions.append("/mall/api/userAuth/mallUserRefreshToken,");//查询服务费用配置
        exclusions.append("/mall/api/userAuth/loginMallUserWechatAuth,");//查询服务费用配置
        exclusions.append("/mall/api/shopMsg.listShopMsg,");//商户消息
        exclusions.append("/mall/api/storeAds/queryStoreAds,");//商户消息
        exclusions.append("/mall/api/product/searchProduct,");//搜索商品
        exclusions.append("/mall/api/shopType/queryShopType,");//查询店铺类型
        exclusions.append("/mall/api/shopVipUser/queryShopVipUser,");//查询是否是店铺会员
        exclusions.append("/mall/api/housekeepingServ/searchHousekeepingServ,");//搜索服务
        exclusions.append("/mall/api/productGroup.listProductGroup,");//拼团商品
        exclusions.append("/mall/api/product/queryGroupProduct,");//拼团商品
        exclusions.append("/mall/api/product/querySeckillProduct,");//秒杀商品

        exclusions.append("/mall/api/productSeckill.listProductSeckill,");//秒杀商品
        exclusions.append("/mall/api/system.listRegisterProtocol,");//秒杀商品
        exclusions.append("/mall/api/user.phoneUserRegister,");//用户注册
        exclusions.append("/mall/api/login.phoneUserLogin,");//用户登陆
        exclusions.append("/mall/api/login.ssoTokenLogin,");//用户登陆
        exclusions.append("/mall/api/login.refreshUserByToken,");//用户登陆
        exclusions.append("/mall/api/wechat.wechatRefreshOpenId,");//刷新openId
        exclusions.append("/mall/api/wechat.wechatNotifyOpenId/*,");//获取openId
        exclusions.append("/mall/api/shop.wuyeRegisterStoreAndShop,");//获取openId
        exclusions.append("/mall/api/login.pcCodeUserLogin,");//根据票据登陆
        exclusions.append("/mall/api/wechat.getShareWechatParam,");//查询分享参数
        exclusions.append("/mall/api/payment.getNativeQrcodePayment,");//查询二维码支付信息
        exclusions.append("/mall/api/payment.testCashier,");//支付
        exclusions.append("/mall/api/payment.cashier,");//支付



        exclusions.append("/mall/api/partner.orderVerification/*,");//海博平台核销

        exclusions.append("/mall/api/payment/notify/wechat/*,");//支付通知
        exclusions.append("/mall/api/chain/callback/*");//手机端商铺注册




        //exclusions.append("/mall/api/appUser.saveAppUser,");// 房屋认证


    }

    @Bean
    public FilterRegistrationBean jwtFilter() {

        final FilterRegistrationBean registrationBean = new FilterRegistrationBean();
        registrationBean.setFilter(new JwtFilter());
        registrationBean.addUrlPatterns("/mall/api/*");
        registrationBean.addUrlPatterns("/app/*");
        registrationBean.addInitParameter("excludedUri", exclusions.toString());

        return registrationBean;
    }

}
